home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / include / Setjmp.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-16  |  2.1 KB  |  103 lines

  1. /* Copyright (C) 1986-2001 by Digital Mars. $Revision: 1.1.1.1 $ */
  2. #if __SC__ || __RCC__
  3. #pragma once
  4. #endif
  5.  
  6. #ifndef __SETJMP_H
  7. #define __SETJMP_H 1
  8.  
  9. #if __cplusplus
  10. extern "C"    {
  11. #endif
  12.  
  13. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  14. #ifndef _CRTAPI1
  15. #define _CRTAPI1 __cdecl
  16. #endif
  17.  
  18. /* Define _CRTAPI2 (for compatibility with the NT SDK) */
  19. #ifndef _CRTAPI2
  20. #define _CRTAPI2 __cdecl
  21. #endif
  22.  
  23. /* Define CRTIMP */
  24. #ifndef _CRTIMP
  25. #if defined(_WIN32) && defined(_DLL)
  26. #define _CRTIMP  __declspec(dllimport)
  27. #else
  28. #define _CRTIMP
  29. #endif
  30. #endif
  31.  
  32. #if defined(_WIN32)
  33. #define _JBLEN 16
  34. #elif __INTSIZE == 4
  35. #define _JBLEN 10
  36. #else
  37. #define _JBLEN 9
  38. #endif
  39.  
  40. typedef int jmp_buf[_JBLEN];
  41.  
  42. #if __OS2__ && __INTSIZE == 4
  43. #define __CLIB    __stdcall
  44. #else
  45. #define __CLIB    __cdecl
  46. #endif
  47.  
  48. #if defined(_WINDOWS) && __INTSIZE == 2
  49. int __far __pascal Catch(int __far *);
  50. void __far __pascal Throw(int const __far *,int);
  51. #define _setjmp(A)    Catch(A)
  52. #define longjmp(A,B) Throw(A,B)
  53. #else
  54. int __CLIB _setjmp(jmp_buf);
  55. int __CLIB setjmp(jmp_buf);  /* prototype provided for backward compatability */
  56. void __CLIB longjmp(jmp_buf,int);
  57.  
  58. #if _WIN32
  59. int __CLIB _inline_setjmp(jmp_buf);
  60. #undef _setjmp
  61. #define _setjmp(x) _inline_setjmp(x)
  62.  
  63. /*
  64.  * Define jump buffer layout for setjmp/longjmp under NT that unwinds stack
  65.  */
  66. typedef struct __JUMP_BUFFER {
  67.     unsigned long Ebp;
  68.     unsigned long Ebx;
  69.     unsigned long Edi;
  70.     unsigned long Esi;
  71.     unsigned long Esp;
  72.     unsigned long Eip;
  73.     unsigned long Except_Registration; 
  74.     unsigned long TryLevel;
  75.     unsigned long Reserved;
  76.     unsigned long Unwind_Handler;
  77.     unsigned long ExceptData[6];
  78. } _JUMP_BUFFER;
  79.  
  80. #endif
  81.  
  82. #if M_UNIX || M_XENIX
  83. #if !__STDC__ || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
  84.  
  85. #define _SIGJBLEN 128
  86.  
  87. typedef int sigjmp_buf[_SIGJBLEN];
  88.  
  89. extern int __CLIB sigsetjmp(sigjmp_buf, int);
  90. extern void __CLIB siglongjmp(sigjmp_buf, int);
  91. #endif
  92. #endif /* M_UNIX || M_XENIX */
  93.  
  94. #endif /* _WINDOWS */
  95.  
  96. #define setjmp _setjmp
  97.  
  98. #if __cplusplus
  99. }
  100. #endif
  101.  
  102. #endif
  103.